//
//  ALAsset+Tools.m
//  MiaoPai
//
//  Created by jiaxuzhou on 2017/6/10.
//  Copyright © 2017年 Jeakin. All rights reserved.
//
//


#import "ALAsset+Tools.h"
#import "ALAssetRepresentation+Tools.h"
#import <objc/runtime.h>


const char * MP_AssetsGroupKey = "AssetsGroupKey";


@implementation ALAsset (Tools)


- (NSString *)mp_MD5Lower16
{
    ALAssetRepresentation * defaultRepresentation = [self defaultRepresentation];
    
    return [defaultRepresentation mp_MD5Lower16];
}

- (NSURL *)mp_getUrl
{
    ALAssetRepresentation * defaultRepresentation = [self defaultRepresentation];
    
    return [defaultRepresentation url];
}

- (NSString *)mp_getUTI
{
    ALAssetRepresentation * defaultRepresentation = [self defaultRepresentation];
    
    return [defaultRepresentation UTI];
}

- (void)mp_setAssetsGroup:(ALAssetsGroup *)assetGroup
{
    objc_setAssociatedObject(self, MP_AssetsGroupKey, assetGroup, OBJC_ASSOCIATION_RETAIN_NONATOMIC);
}

- (ALAssetsGroup *)mp_getAssetsGroup
{
    return (ALAssetsGroup *)objc_getAssociatedObject(self, MP_AssetsGroupKey);
}

- (void)mp_dump
{
    NSLog(@"ALAssetPropertyType: %@", [self valueForProperty:ALAssetPropertyType]);
    NSLog(@"ALAssetPropertyLocation: %@", [self valueForProperty:ALAssetPropertyLocation]);
    NSLog(@"ALAssetPropertyDuration: %@", [self valueForProperty:ALAssetPropertyDuration]);
    NSLog(@"ALAssetPropertyOrientation: %@", [self valueForProperty:ALAssetPropertyOrientation]);
    NSLog(@"ALAssetPropertyDate: %f", [[self valueForProperty:ALAssetPropertyDate] timeIntervalSince1970]);
    NSLog(@"ALAssetPropertyRepresentations: %@", [self valueForProperty:ALAssetPropertyRepresentations]);
    NSLog(@"ALAssetPropertyURLs: %@", [self valueForProperty:ALAssetPropertyURLs]);
}


@end
